home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Communication / NewsBase / Source / IFolderDockCell.m < prev    next >
Text File  |  1993-01-12  |  3KB  |  122 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. #import "IFolderDockCell.h"
  5. #import "IFolderMatrix.h"
  6.  
  7. #import <appkit/NXImage.h>
  8. #import <dpsclient/dpsNeXT.h>
  9. #import <dpsclient/wraps.h>
  10. #import <string.h>
  11.  
  12. @implementation IFolderDockCell
  13.  
  14. - initIconCell:(const char *)iconName
  15. {
  16.     [super initIconCell:iconName];
  17.     iCurrentImage = NULL;
  18.     return self;
  19. }
  20.  
  21. - setCurrentImage:currentImage
  22. {
  23.     iCurrentImage = currentImage;
  24.     return self;
  25. }
  26.  
  27. - currentImage
  28. {
  29.     return (iCurrentImage);
  30. }
  31.  
  32. - drawInside:(const NXRect *)cellFrame inView:controlView
  33. {
  34.     NXRect    iconFrame;
  35.     NXPoint    iconOrigin;
  36.     
  37.     // do normal stuff
  38.     [super drawInside:cellFrame inView:controlView];
  39.     
  40.     // if cell has current image, draw ghost of it
  41.     // current image is set when dragging icon come across over this cell
  42.     if (iCurrentImage != NULL) {
  43.     iconFrame = *cellFrame;
  44.     [self getIconRect:&iconFrame];
  45.     iconOrigin = iconFrame.origin;
  46.     if ([controlView isFlipped] == YES) {
  47.         // control view is Matrix, so usually control view's coordinate
  48.         // is Flipped. 
  49.         iconOrigin.y = iconFrame.origin.y + iconFrame.size.height;
  50.     }
  51.     [iCurrentImage composite:NX_SOVER toPoint:&(iconOrigin)];
  52.     PSsetalpha(0.5);
  53.     PSsetgray(NX_LTGRAY);
  54.     PScompositerect(iconFrame.origin.x, iconFrame.origin.y, 
  55.             iconFrame.size.width, iconFrame.size.height,
  56.             NX_SOVER);
  57.     }
  58.         
  59.     return self;
  60. }
  61.  
  62. - (BOOL)windowEntered:dragSource controlView:cView
  63. {
  64.     id        image;
  65.  
  66.     if ((image =[dragSource image]) == [NXImage findImageNamed:CLOSEDFOLDER]
  67.             && (strcmp([[self image] name], BLANKICON) == 0)) {
  68.     // dragged window is newsgroup folder and this cell has no folder
  69.     iCurrentImage = image;
  70.     [[cView window] disableFlushWindow];
  71.     [cView drawCell:self];
  72.     [[cView window] reenableFlushWindow];
  73.     return YES;
  74.     } else {
  75.     // dragged icon may be file's one to post
  76.     return ([super windowEntered:dragSource controlView:cView]);
  77.     }
  78. }
  79.     
  80. - (BOOL)windowExited:dragSource controlView:cView
  81. {
  82.     id        image;
  83.     
  84.     if ((image =[dragSource image]) == [NXImage findImageNamed:CLOSEDFOLDER]
  85.             && (strcmp([[self image] name], BLANKICON) == 0)) {
  86.     // dragged window is newsgroup folder and this cell has no folder
  87.     iCurrentImage = NULL;
  88.     [[cView window] disableFlushWindow];
  89.     [cView drawCell:self];
  90.     [[cView window] reenableFlushWindow];
  91.     return YES;
  92.     } else {
  93.     // dragged icon may be file's one to post
  94.     return ([super windowExited:dragSource controlView:cView]);
  95.     }
  96. }
  97.  
  98. - (BOOL)windowDropped:dragSource controlView:cView
  99. {
  100.     id        image;
  101.     
  102.     if ((image =[dragSource image]) == [NXImage findImageNamed:CLOSEDFOLDER]) {
  103.         if (strcmp([[self image] name], BLANKICON) == 0) {
  104.         // dragged window is newsgroup folder and this cell has no folder
  105.         iCurrentImage = NULL;
  106.         [self setImage:image];
  107.         [self setTitle:[dragSource title]];
  108.         [cView drawCell:self];
  109.         return YES;
  110.     } else if (strcmp([[self image] name], BLANKICON) != 0) {
  111.         // folder has already another image, so dragged newsfolder
  112.         // icon will be refused
  113.         return NO;
  114.     }
  115.     } else {
  116.     return ([super windowDropped:dragSource controlView:cView]);
  117.     }
  118.     return YES;        // dummy statement for fool compiler
  119. }
  120.  
  121. @end
  122.